package com.zhongyouyun.admin.model;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.zhongyouyun.other.model.TreeModel;
import com.zhongyouyun.utils.ImageUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import lombok.ToString;
import lombok.experimental.Accessors;

/**
 * @Author: shenyi
 * @Date: 2021-09-23
 * @Description: 资源表
 */

@ApiModel(value = "MenuModel对象", description = "菜单")
@Data
@TableName("z_menu")
@Accessors(chain = true)
public class MenuModel implements Serializable, TreeModel<MenuModel> {


    @ApiModelProperty(value = "主键")
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    @ApiModelProperty(value = "项目类型")
    @TableField("xiangmu_type")
    private String xiangMuType;


    @ApiModelProperty(value = "图标")
    @TableField("icon")
    private String icon;


    @ApiModelProperty(value = "排序")
    @TableField("order_num")
    private Integer orderNum;


    @ApiModelProperty(value = "名称")
    @TableField("name")
    private String name;

    @ApiModelProperty(value = "地址")
    @TableField("path")
    private String path;

    @ApiModelProperty(value = "文件路径")
    @TableField("component")
    private String component;

    @ApiModelProperty(value = "状态")
    @TableField("state")
    private String state;

    @ApiModelProperty(value = "父级Id")
    @TableField("p_id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long pId;

    public void setpId(final Long pId) {
        this.pId = pId;
    }

    @ApiModelProperty(value = "类型")
    @TableField("type")
    private String type;

    @ApiModelProperty(value = "权限")
    @TableField("perms")
    private String perms;

    @ApiModelProperty(value = "是否可以删除")
    @TableField("is_del")
    private Integer idDel;

    @ApiModelProperty(value = "创建人")
    @TableField("createBy")
    private String createBy;

    @ApiModelProperty(value = "创建时间")
    @TableField("createTime")
    private Date createTime;

    @ApiModelProperty(value = "修改人")
    @TableField("updateBy")
    private String updateBy;

    @ApiModelProperty(value = "修改时间")
    @TableField("updateTime")
    private Date updateTime;

    @ApiModelProperty(value = "备注")
    @TableField("remark")
    private String remark;

    @ApiModelProperty(value = "菜单子级")
    @TableField(exist = false)
    private List<MenuModel> routes;



    @ApiModelProperty(value = "是否可以修改")
    @TableField(exist = false)
    private Boolean update;

    @TableField(exist = false)
    @JsonIgnore
    private List<DictModel> dictModelList;


/*    public List<MenuModel> getRoutes() {
        if (ObjectUtil.isEmpty(this.routes)){
            this.routes=new ArrayList<MenuModel>();
        }
        return this.routes;
    }*/
}